﻿using DevComponents.DotNetBar.SuperGrid;
//using Evision.Insure;
//using Evision.Insure.Forms;
using Microsoft.VisualBasic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Zlsy.Core.ZlhisModule;

namespace Evision.Zlhis.FeeType.Personnel.Maintenance {
    public partial class 费别人员维护工号选择 : BaseForm {
        public string No { get; set; }
        public string DocName { get; set; }
        public string ApprovalType { get; set; }
        public 费别人员维护工号选择() {
            InitializeComponent();
        }
        private void 特殊费别审批工号选择_Load(object sender, EventArgs e) {
            sgc.PrimaryGrid.ReadOnly = true;
            //string strMsg = "";
            //object gobjRegister = Interaction.CreateObject("zlRegister.clsRegister");
            //ADODB.Connection gcnOracle = (ADODB.Connection)gobjRegister.GetType().InvokeMember("GetConnection", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.InvokeMethod,
            //    null, gobjRegister, new object[] { "SYTEST", "ZLHIS", "AQA", true, 1, strMsg });
            //Adodb.Init(gcnOracle);
            DataTable dt = new DataTable();
            List<Object> parm = new List<object>();
            if (string.IsNullOrEmpty(No)) {
                dt = Adodb.QueryForTable("select 编号,姓名,性别,简码,身份证号,专业技术职务 from 人员表");
                sgc.PrimaryGrid.DataSource = dt;
                return;
            }
            StringBuilder sql = new StringBuilder(@"select 编号,姓名,性别,简码,身份证号,专业技术职务 from 人员表 where 1=1");
            if (!string.IsNullOrEmpty(No)) {
                sql.Append(" and 编号 LIKE ?");
                parm.Add(No + "%");
            }
            dt = Adodb.QueryForTable(sql.ToString(), parm.ToArray());
            sgc.PrimaryGrid.DataSource = dt;
        }
        private void btnOk_Click(object sender, EventArgs e) {
            GridRow row = this.sgc.PrimaryGrid.ActiveRow as GridRow;
            this.No = row.Cells["编号"].Value.ToString();
            this.DocName = row.Cells["姓名"].Value.ToString();
            DialogResult = DialogResult.OK;
        }

        private void txtFilter_KeyDown(object sender, KeyEventArgs e) {
            if(e.KeyCode == Keys.Enter) {
                StringBuilder parm = new StringBuilder(@"select 编号,姓名,性别,简码,身份证号,专业技术职务 from 人员表 where 1=1");
                List<Object> list = new List<object>();
                parm.Append(" and 姓名 LIKE ?");
                list.Add(txtFilter.Text +"%");
                DataTable dt =Adodb.QueryForTable(parm.ToString(),list.ToArray());
                sgc.PrimaryGrid.DataSource = dt;
            }
        }

        private void sgc_CellDoubleClick(object sender, GridCellDoubleClickEventArgs e) {
            GridRow row = this.sgc.PrimaryGrid.ActiveRow as GridRow;
            this.No = row.Cells["编号"].Value.ToString();
            this.DocName = row.Cells["姓名"].Value.ToString();
            DialogResult = DialogResult.OK;
        }
    }
}
